#include <cassert>
#include <algorithm>
#include <iterator>

#include "is_sorted.c++"
#include "3-heap.c++"

template <typename position, typename ordering>
void test_sort(position a, position b, const ordering& less) {
  typedef typename std::iterator_traits<position>::value_type element;
  std::vector<element> t(b - a);
  std::copy(a, b, t.begin());
    
  std::sort(t.begin(), t.end(), ordering());

  //std::cout << "before make_heap: ";
  //show(a, b);

  make_dheap(a, b, less);

  //std::cout << "before sort_heap:";
  //show(a, b);

  sort_dheap(a, b, less);

  //std::cout << "after sort_heap: ";
  //show(a, b);

  assert(cphstl::is_sorted(a, b, less));
  assert(std::equal(a, b, t.begin()));
}

template <typename position, typename ordering>
void own_sort(position a, position b, const ordering& less) {
  make_dheap(a, b, less);
  sort_dheap(a, b, less);
}

